/*
 * PhysicsElement.h
 *
 *  Created on: 17/11/2012
 *      Author: san
 */

#ifndef PHYSICSELEMENT_H_
#define PHYSICSELEMENT_H_
#include "IPositionable.h"
#include "Vector2D.h"
#include "GameSettings.h"
class PhysicsElement : public IPositionable {
protected:
	double x;
	double y;
	int hp, dmgToPig, dmgToBox, dmgToBird;
	bool physicallyStatic;
	float weight;
	bool disposable;
	Vector2D speed;
	unsigned char collisionMask;
    double collisionRadius;
    virtual void onCollisionReaction(PhysicsElement &other);
	virtual void onCollisionResponse(PhysicsElement &other) = 0;
public:
	PhysicsElement(double x = 0, double y = 0, int hp = 0, int dmgToPig = 0, int dmgToBox = 0, int dmgToBird = 0, bool physicallyStatic = false, float weight = NO_WEIGHT_FACTOR, unsigned char collisionMask = MASK_BIRD, double collisionRadius = 0);
	PhysicsElement(const PhysicsElement& p);
	// IPositionable
	virtual void setX(double x);
	virtual double getX() const;
	virtual void setY(double y);
	virtual double getY() const;

	void setSpeed(Vector2D speed);
	Vector2D getSpeed() const;
	void setPhysicallyStatic(bool gravity);
	bool getPhysicallyStatic() const;
	void translate(double x, double y);
	bool isDisposable() const;
	void setDisposable(bool state);
	float getWeight() const;
	void setWeight(float value);
	void setHitPoints(int hp);
	int getHitPoints() const;
	// Damage
	void setDamageToPig(int dmg);
	int getDamageToPig() const;
	void setDamageToBox(int dmg);
	int getDamageToBox() const;
	void setDamageToBird(int dmg);
	int getDamageToBird() const;
	void beHit(int dmg);
	// Collisions
    virtual void setCollisionMask(unsigned char mask);
    unsigned char getCollisionMask() const;
	virtual void checkCollision(PhysicsElement &other);
	double getCollisionRadius() const;
    void setCollisionRadius(double width);
	virtual ~PhysicsElement();
};

#endif /* PHYSICSELEMENT_H_ */
